Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: make sidebar resizable #5219

Merged
merged 4 commits into from
Aug 11, 2021
Merged

Conversation

stephanwlee
Copy link
Contributor

This change introduces new layout component that you can use to have
consistent layout in a plugin. This layout component is responsible for
interactions and remembering the last set width.

image

This change introduces new layout component that you can use to have
consistent layout in a plugin. This layout component is responsible for
interactions and remembering the last set width.
Copy link
Contributor

@psybuzz psybuzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: In some products, the sidebar width is set using an absolute unit (e.g. px) rather than as a percentage, so that resizing the browser window doesn't affect all the sidebar widths inside. Would it make more sense to set 'px' instead?

import {MouseEventButtons} from '../../util/dom';

@Component({
selector: 'tb-layout',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider including "resizable" in the name, e.g. "tb-resizable-layout", for more descriptiveness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am iffy about that. I want this to be used in all pages' layout when possible like https://github.com/tensorflow/tensorboard/blob/master/tensorboard/components/tf_dashboard_common/tf-dashboard-layout.ts#L23 and whether it is resizable or not is not the part I want plugin authors to care/know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, then perhaps something along the lines of tb-dashboard-layout or tb-plugin-dashboard-layout? With tb-layout, it's unclear to me when it should be used.

tensorboard/webapp/core/views/layout_container.scss Outdated Show resolved Hide resolved
return createSelector<State, number, PersistableSettings>(
getSideBarWidthInPercent,
(sideBarWidthInPercent) => {
return {sideBarWidthInPercent};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we plan to ever have another resizable layout in the UI later on, which also needs its width persisted, it would be reasonable to separately store their widths. To prevent future ambiguity as to which sidebar this setting refers to, would it reasonable to name this property something specific like metricsRunSidebarWidth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my comment below makes this obsolete.

@@ -37,6 +37,8 @@ export interface CoreState {
// For now, we want them here for Polymer interop states reasons, too.
polymerInteropRuns: Run[];
polymerInteropRunSelection: Set<RunId>;
// Number between 0 and 100.
sideBarWidthInPercent: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally expected to see the value stored under metrics/, since it is specific to Time Series UI. Having it under core/ makes sense when under the assumption that there will not be other resizable layouts. Would it be better to move this field, the reducer, selector, etc to metrics/ as "(get)metricsRunSidebarWidth", if we want other features besides metrics/ to have persisted sidebar widths? e.g. maybe the Hparams dashboard remembers its own sidebar width separately in the future.

If not, could we at least add comments to here and in the selector definition that mention it is specific to Time Series' run sidebar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new layout component that you can use to have
consistent layout in a plugin.

This component is expected to be used by other plugins as the description indicates.

For instance, I want this to be usable in npmi plugin which I have in a follow up change. I think it makes sense for all sidebar widths to be linked thus this state remains in the Core plugin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, I see where this is going now. This setting and the tb-layout component isn't to be used to make any resizable sidebar, (e.g. not to be used for cases like the Time Series settings pane), but specifically only for replacing the top-level layout for each plugin dashboard.

@stephanwlee
Copy link
Contributor Author

optional: In some products, the sidebar width is set using an absolute unit (e.g. px) rather than as a percentage, so that resizing the browser window doesn't affect all the sidebar widths inside. Would it make more sense to set 'px' instead?

The opposite was what I was looking for. I wanted the width of the sidebar to be relative to the size of the window which often is what I am looking for in a UI.

import {MouseEventButtons} from '../../util/dom';

@Component({
selector: 'tb-layout',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, then perhaps something along the lines of tb-dashboard-layout or tb-plugin-dashboard-layout? With tb-layout, it's unclear to me when it should be used.

@@ -37,6 +37,8 @@ export interface CoreState {
// For now, we want them here for Polymer interop states reasons, too.
polymerInteropRuns: Run[];
polymerInteropRunSelection: Set<RunId>;
// Number between 0 and 100.
sideBarWidthInPercent: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, I see where this is going now. This setting and the tb-layout component isn't to be used to make any resizable sidebar, (e.g. not to be used for cases like the Time Series settings pane), but specifically only for replacing the top-level layout for each plugin dashboard.

@stephanwlee stephanwlee merged commit d87da10 into tensorflow:master Aug 11, 2021
@stephanwlee stephanwlee deleted the width branch August 11, 2021 02:02
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
This change introduces new layout component that you can use to have
consistent layout in a plugin. This layout component is responsible for
interactions and remembering the last set width.
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
This change introduces new layout component that you can use to have
consistent layout in a plugin. This layout component is responsible for
interactions and remembering the last set width.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants